Skip to content

ObjectMixin

Sub classes

Name Children Inherits
Object
prettyqt.core.object
The base class of all Qt objects.
SocketNotifier
prettyqt.core.socketnotifier
Support for monitoring activity on a file descriptor.
    SharedMemory
    prettyqt.core.sharedmemory
    Access to a shared memory segment.
      SignalMapper
      prettyqt.core.signalmapper
      Bundles signals from identifiable senders.
        TimeLine
        prettyqt.core.timeline
        Timeline for controlling animations.
          AbstractEventDispatcher
          prettyqt.core.abstracteventdispatcher
          Interface to manage Qt's event queue.
            EventLoop
            prettyqt.core.eventloop
            Means of entering and leaving an event loop.
              AbstractAnimationMixin
              prettyqt.core.abstractanimation
              The base of all animations.
              TranslatorMixin
              prettyqt.core.translator
              CoreApplicationMixin
              prettyqt.core.coreapplication
              FileSystemWatcher
              prettyqt.core.filesystemwatcher
              Interface for monitoring files and directories for modifications.
                FileSelector
                prettyqt.core.fileselector
                Convenient way of selecting file variants.
                  IODeviceMixin
                  prettyqt.core.iodevice
                  Settings_
                  prettyqt.core.settings
                  Persistent platform-independent application settings.
                  Timer
                  prettyqt.core.timer
                  Repetitive and single-shot timers.
                  • AnimationTimer
                  Thread
                  prettyqt.core.thread
                  Platform-independent way to manage threads.
                    MimeData
                    prettyqt.core.mimedata
                    Container for data that records information about its MIME type.
                      ThreadPool
                      prettyqt.core.threadpool
                      Manages a collection of QThreads.
                        ItemSelectionModel
                        prettyqt.core.itemselectionmodel
                        Keeps track of a view's selected items.
                        AbstractItemModelMixin
                        prettyqt.core.abstractitemmodel
                        Library
                        prettyqt.core.library
                        Loads shared libraries at runtime.
                          PluginLoader
                          prettyqt.core.pluginloader
                          Load a plugin at runtime.
                            AccessibilityHintsMixin
                            prettyqt.gui.accessibilityhints
                            StyleHintsMixin
                            prettyqt.gui.stylehints
                            Shortcut
                            prettyqt.gui.shortcut
                              Drag
                              prettyqt.gui.drag
                              Support for MIME-based drag and drop data transfer.
                                WindowMixin
                                prettyqt.gui.window
                                Clipboard
                                prettyqt.gui.clipboard
                                Access to the window system clipboard.
                                  InputMethod
                                  prettyqt.gui.inputmethod
                                    SessionManager
                                    prettyqt.gui.sessionmanager
                                      ValidatorMixin
                                      prettyqt.gui.validator
                                      TextDocumentMixin
                                      prettyqt.gui.textdocument
                                      Movie
                                      prettyqt.gui.movie
                                      Convenience class for playing movies with QImageReader.
                                        PdfWriter
                                        prettyqt.gui.pdfwriter
                                        Class to generate PDFs that can be used as a paint device.
                                          TextObjectMixin
                                          prettyqt.gui.textobject
                                          AbstractTextDocumentLayoutMixin
                                          prettyqt.gui.abstracttextdocumentlayout
                                          SyntaxHighlighterMixin
                                          prettyqt.gui.syntaxhighlighter
                                          UndoStackMixin
                                          prettyqt.gui.undostack
                                          UndoGroupMixin
                                          prettyqt.gui.undogroup
                                          ActionMixin
                                          prettyqt.gui.action
                                          ActionGroup
                                          prettyqt.gui.actiongroup
                                          Groups actions together.
                                            StyleMixin
                                            prettyqt.widgets.style
                                            WidgetMixin
                                            prettyqt.widgets.widget
                                            GraphicsTransformMixin
                                            prettyqt.widgets.graphicstransform
                                            GraphicsObjectMixin
                                            prettyqt.widgets.graphicsobject
                                            GraphicsAnchor
                                            prettyqt.widgets.graphicsanchor
                                            Represents an anchor between two items in a QGraphicsAnchorLayout.
                                              GraphicsEffectMixin
                                              prettyqt.widgets.graphicseffect
                                              GraphicsScene
                                              prettyqt.widgets.graphicsscene
                                              Surface for managing a large number of 2D graphical items.
                                                Completer
                                                prettyqt.widgets.completer
                                                Completions based on an item model.
                                                Scroller
                                                prettyqt.widgets.scroller
                                                Enables kinetic scrolling for any scrolling widget or graphics item.
                                                  AbstractItemDelegateMixin
                                                  prettyqt.widgets.abstractitemdelegate
                                                  SystemTrayIcon
                                                  prettyqt.widgets.systemtrayicon
                                                  Icon for an application in the system tray.
                                                    LayoutMixin
                                                    prettyqt.widgets.layout
                                                    ButtonGroup
                                                    prettyqt.widgets.buttongroup
                                                    Container to organize groups of button widgets.
                                                      DataWidgetMapper
                                                      prettyqt.widgets.datawidgetmapper
                                                      Mapping between a section of a data model to widgets.
                                                        GestureMixin
                                                        prettyqt.widgets.gesture
                                                        BluetoothLocalDevice
                                                        prettyqt.bluetooth.bluetoothlocaldevice
                                                        Enables access to the local Bluetooth device.
                                                          BluetoothServer
                                                          prettyqt.bluetooth.bluetoothserver
                                                          Uses the RFCOMM or L2cap protocol to communicate with a Bluetooth device.
                                                            BluetoothDeviceDiscoveryAgent
                                                            prettyqt.bluetooth.bluetoothdevicediscoveryagent
                                                            Discovers the Bluetooth devices nearby.
                                                              BluetoothServiceDiscoveryAgent
                                                              prettyqt.bluetooth.bluetoothservicediscoveryagent
                                                              Enables you to query for Bluetooth services.
                                                                BarSet
                                                                prettyqt.charts.barset
                                                                  BoxSet
                                                                  prettyqt.charts.boxset
                                                                    CandlestickSet
                                                                    prettyqt.charts.candlestickset
                                                                      PieSlice
                                                                      prettyqt.charts.pieslice
                                                                        AbstractAxisMixin
                                                                        prettyqt.charts.abstractaxis
                                                                        AbstractSeriesMixin
                                                                        prettyqt.charts.abstractseries
                                                                        PyDesignerTaskMenuExtension
                                                                        prettyqt.designer.pydesignertaskmenuextension
                                                                          DesignerFormEditorInterface
                                                                          prettyqt.designer.designerformeditorinterface
                                                                          Allows you to access Qt Designer's various components.
                                                                            GeoPositionInfoSourceMixin
                                                                            prettyqt.positioning.geopositioninfosource
                                                                            GeoSatelliteInfoSource
                                                                            prettyqt.positioning.geosatelliteinfosource
                                                                              GeoAreaMonitorSource
                                                                              prettyqt.positioning.geoareamonitorsource
                                                                                GeoCodingManager
                                                                                prettyqt.location.geocodingmanager
                                                                                Support for geocoding operations.
                                                                                  GeoRoutingManager
                                                                                  prettyqt.location.georoutingmanager
                                                                                  Support for geographic routing operations.
                                                                                    PlaceReplyMixin
                                                                                    prettyqt.location.placereply
                                                                                    GeoServiceProvider
                                                                                    prettyqt.location.geoserviceprovider
                                                                                    Aggregates access to services which provide geographical information.
                                                                                      Camera
                                                                                      prettyqt.multimedia.camera
                                                                                        MediaPlayer
                                                                                        prettyqt.multimedia.mediaplayer
                                                                                          ScreenCapture
                                                                                          prettyqt.multimedia.screencapture
                                                                                            MediaRecorder
                                                                                            prettyqt.multimedia.mediarecorder
                                                                                              NetworkCookieJar
                                                                                              prettyqt.network.networkcookiejar
                                                                                              Implements a simple jar of QNetworkCookie objects.
                                                                                                LocalServer
                                                                                                prettyqt.network.localserver
                                                                                                Local socket based server.
                                                                                                  TcpServer
                                                                                                  prettyqt.network.tcpserver
                                                                                                  TCP-based server.
                                                                                                    HttpMultiPart
                                                                                                    prettyqt.network.httpmultipart
                                                                                                    Resembles a MIME multipart message to be sent over HTTP.
                                                                                                      NetworkAccessManager
                                                                                                      prettyqt.network.networkaccessmanager
                                                                                                      Allows the application to send network requests and receive replies.
                                                                                                        RestAccessManager
                                                                                                        prettyqt.network.restaccessmanager
                                                                                                        Convenience wrapper around QNetworkAccessManager for RESTful APIs.
                                                                                                          PdfDocument
                                                                                                          prettyqt.pdf.pdfdocument
                                                                                                          Loads a PDF document and renders pages from it.
                                                                                                            QmlExpression
                                                                                                            prettyqt.qml.qmlexpression
                                                                                                            Evaluates JavaScript in a QML context.
                                                                                                              QmlPropertyMapMixin
                                                                                                              prettyqt.qml.qmlpropertymap
                                                                                                              JSEngineMixin
                                                                                                              prettyqt.qml.jsengine
                                                                                                              QmlComponent
                                                                                                              prettyqt.qml.qmlcomponent
                                                                                                              Encapsulates a QML component definition.
                                                                                                                HelpEngineCoreMixin
                                                                                                                prettyqt.qthelp.helpenginecore
                                                                                                                The core functionality of the help system.
                                                                                                                HelpSearchEngine
                                                                                                                prettyqt.qthelp.helpsearchengine
                                                                                                                Access to widgets reusable to integrate fulltext search.
                                                                                                                  HelpFilterEngine
                                                                                                                  prettyqt.qthelp.helpfilterengine
                                                                                                                  Filtered view of the help contents.
                                                                                                                    QuickTextDocument
                                                                                                                    prettyqt.quick.quicktextdocument
                                                                                                                    Access to the QTextDocument of QQuickTextEdit.
                                                                                                                      QuickRenderControl
                                                                                                                      prettyqt.quick.quickrendercontrol
                                                                                                                      Mechanism for rendering the Qt Quick scenegraph onto an offscreen render target.
                                                                                                                        QuickImageResponse
                                                                                                                        prettyqt.quick.quickimageresponse
                                                                                                                        Interface for asynchronous image loading in QQuickAsyncImageProvider.
                                                                                                                          QuickItemGrabResult
                                                                                                                          prettyqt.quick.quickitemgrabresult
                                                                                                                          Contains the result from QQuickItem::grabToImage().
                                                                                                                            QuickItemMixin
                                                                                                                            prettyqt.quick.quickitem
                                                                                                                            ScxmlStateMachine
                                                                                                                            prettyqt.scxml.scxmlstatemachine
                                                                                                                            Interface to the state machines created from SCXML files.
                                                                                                                              ScxmlDataModelMixin
                                                                                                                              prettyqt.scxml.scxmldatamodel
                                                                                                                              ScxmlInvokableService
                                                                                                                              prettyqt.scxml.scxmlinvokableservice
                                                                                                                              The base class for services called from state machines.
                                                                                                                                ScxmlInvokableServiceFactory
                                                                                                                                prettyqt.scxml.scxmlinvokableservicefactory
                                                                                                                                Creates invokable service instances.
                                                                                                                                  AmbientSound
                                                                                                                                  prettyqt.spatialaudio.ambientsound
                                                                                                                                  A stereo overlay sound.
                                                                                                                                    AudioEngine
                                                                                                                                    prettyqt.spatialaudio.audioengine
                                                                                                                                    Manages a three dimensional sound field.
                                                                                                                                      AudioListener
                                                                                                                                      prettyqt.spatialaudio.audiolistener
                                                                                                                                      Defines the position and orientation of the person listening to a sound field.
                                                                                                                                        AudioRoom
                                                                                                                                        prettyqt.spatialaudio.audioroom
                                                                                                                                        Represents a room with its acoustic properties.
                                                                                                                                          SpatialSound
                                                                                                                                          prettyqt.spatialaudio.spatialsound
                                                                                                                                          A sound object in 3D space.
                                                                                                                                            AbstractStateMixin
                                                                                                                                            prettyqt.statemachine.abstractstate
                                                                                                                                            AbstractTransitionMixin
                                                                                                                                            prettyqt.statemachine.abstracttransition
                                                                                                                                            SvgRenderer
                                                                                                                                            prettyqt.svg.svgrenderer
                                                                                                                                              TextToSpeech
                                                                                                                                              prettyqt.texttospeech.texttospeech
                                                                                                                                                WebChannel
                                                                                                                                                prettyqt.webchannel.webchannel
                                                                                                                                                  WebEngineUrlSchemeHandler
                                                                                                                                                  prettyqt.webenginecore.webengineurlschemehandler
                                                                                                                                                  • CallbackWebEngineUrlSchemeHandler
                                                                                                                                                  WebEnginePage
                                                                                                                                                  prettyqt.webenginecore.webenginepage
                                                                                                                                                  A web engine page holds the HTML document contents, link history + actions.
                                                                                                                                                    WebEngineProfile
                                                                                                                                                    prettyqt.webenginecore.webengineprofile

                                                                                                                                                      🛈 DocStrings

                                                                                                                                                      Bases: _ObjectBase

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      class ObjectMixin(_ObjectBase):
                                                                                                                                                          def __init__(self, *args, **kwargs):
                                                                                                                                                              self._eventfilters = set()
                                                                                                                                                              # klass = type(self)
                                                                                                                                                              # if issubclass(klass, core.QObject) and klass not in _properties:
                                                                                                                                                              #     metaobj = core.MetaObject(klass.staticMetaObject)
                                                                                                                                                              #     _properties[klass] = [i.get_name() for i in metaobj.get_properties()]
                                                                                                                                                              #     _signals[klass] = [i.get_name() for i in metaobj.get_signals()]
                                                                                                                                                              new: dict[str, Any] = {}
                                                                                                                                                              if kwargs:
                                                                                                                                                                  mapper = self._get_map()
                                                                                                                                                                  props = get_properties(type(self))
                                                                                                                                                                  signals = get_signals(type(self))
                                                                                                                                                                  for k, v in kwargs.items():
                                                                                                                                                                      # this allows snake_case naming.
                                                                                                                                                                      camel_k = helpers.to_lower_camel(k)
                                                                                                                                                                      if camel_k != k and camel_k in kwargs:
                                                                                                                                                                          logger.warning("%s defined twice: %s / %s", k, v, kwargs[camel_k])
                                                                                                                                                                      # allow str values instead of enum
                                                                                                                                                                      if camel_k in mapper and isinstance(v, str):
                                                                                                                                                                          new[camel_k] = mapper[camel_k][v]
                                                                                                                                                                      # allow str values for common icon kwargs
                                                                                                                                                                      elif camel_k in {"windowIcon", "icon"} and isinstance(v, str):
                                                                                                                                                                          from prettyqt import iconprovider
                                                                                                                                                      
                                                                                                                                                                          new[camel_k] = iconprovider.get_icon(v)
                                                                                                                                                                      # kwargs which need camel-casing
                                                                                                                                                                      elif camel_k in props or camel_k in signals:
                                                                                                                                                                          new[camel_k] = v
                                                                                                                                                                      else:
                                                                                                                                                                          new[k] = v
                                                                                                                                                              super().__init__(*args, **new)
                                                                                                                                                      
                                                                                                                                                          def _get_map(self):
                                                                                                                                                              """Can be implemented by subclasses to support str -> Enum conversion.
                                                                                                                                                      
                                                                                                                                                              To get data from all subclasses, we always fetch _get_map from super(),
                                                                                                                                                              append our own shit and return it.
                                                                                                                                                              """
                                                                                                                                                              return {}
                                                                                                                                                      
                                                                                                                                                          def __pretty__(self, fmt: Callable[[Any], Any], **kwargs: Any) -> Generator[Any]:
                                                                                                                                                              yield f"{type(self).__name__}("
                                                                                                                                                              yield 1
                                                                                                                                                              for k, v in self.get_properties(only_writable=True).items():
                                                                                                                                                                  yield f"{k}={v!r}"
                                                                                                                                                                  yield 0
                                                                                                                                                                  for ef in self._eventfilters:
                                                                                                                                                                      yield f"Eventfilter={ef.__class__.__name__}"
                                                                                                                                                                      yield 0
                                                                                                                                                              yield -1
                                                                                                                                                              yield ")"
                                                                                                                                                      
                                                                                                                                                          # def __repr__(self):  # we already monkeypatch QObject
                                                                                                                                                          #     return get_repr(self, self.objectName())
                                                                                                                                                      
                                                                                                                                                          def __setstate__(self, state):
                                                                                                                                                              self.set_properties(state)
                                                                                                                                                      
                                                                                                                                                          def __getstate__(self):
                                                                                                                                                              return self.get_properties()
                                                                                                                                                      
                                                                                                                                                          def __reduce__(self):
                                                                                                                                                              return type(self), (), self.__getstate__()
                                                                                                                                                      
                                                                                                                                                          def installEventFilter(self, filter_: core.QObject | str, **kwargs):
                                                                                                                                                              """Override to also allow setting eventfilters by name."""
                                                                                                                                                              if filter_ in self._eventfilters:
                                                                                                                                                                  logger.warning("Installing same EventFilter multiple times to %s.", self)
                                                                                                                                                                  return
                                                                                                                                                              match filter_:
                                                                                                                                                                  case core.QObject():
                                                                                                                                                                      pass
                                                                                                                                                                  case str():
                                                                                                                                                                      from prettyqt import eventfilters
                                                                                                                                                      
                                                                                                                                                                      kls = classhelpers.get_class_for_id(eventfilters.BaseEventFilter, filter_)
                                                                                                                                                                      filter_ = kls(parent=self, **kwargs)
                                                                                                                                                                  case _:
                                                                                                                                                                      raise ValueError(filter_)
                                                                                                                                                              self._eventfilters.add(filter_)
                                                                                                                                                              super().installEventFilter(filter_)
                                                                                                                                                      
                                                                                                                                                          def removeEventFilter(self, eventfilter: core.QObject):
                                                                                                                                                              if eventfilter not in self._eventfilters:
                                                                                                                                                                  logger.warning("Trying to remove non-installed EventFilter.")
                                                                                                                                                                  return
                                                                                                                                                              self._eventfilters.remove(eventfilter)
                                                                                                                                                              super().removeEventFilter(eventfilter)
                                                                                                                                                      
                                                                                                                                                          def add_callback_for_event(
                                                                                                                                                              self,
                                                                                                                                                              callback: Callable[[core.QEvent], bool],
                                                                                                                                                              include: core.QEvent.Type
                                                                                                                                                              | core.event.TypeStr
                                                                                                                                                              | Sequence[core.QEvent.Type | core.event.TypeStr]
                                                                                                                                                              | None = None,
                                                                                                                                                              exclude: core.QEvent.Type
                                                                                                                                                              | core.event.TypeStr
                                                                                                                                                              | Sequence[core.QEvent.Type | core.event.TypeStr]
                                                                                                                                                              | None = None,
                                                                                                                                                          ) -> eventfilters.EventCatcher:
                                                                                                                                                              """Connect widget events to a callback.
                                                                                                                                                      
                                                                                                                                                              if include is set, it behaves like a whitelist.
                                                                                                                                                              if exclude is set, it behaves like a blacklist.
                                                                                                                                                              The QEvent is passed to the callback as an argument, and the callback
                                                                                                                                                              needs to return True or False to indicate whether the Event should be filtered.
                                                                                                                                                      
                                                                                                                                                              Arguments:
                                                                                                                                                                  callback: Callback to execute when event is triggered
                                                                                                                                                                  include: Events to include
                                                                                                                                                                  exclude: Events to exclude
                                                                                                                                                              """
                                                                                                                                                              from prettyqt import eventfilters
                                                                                                                                                      
                                                                                                                                                              eventfilter = eventfilters.EventCatcher(include, exclude, callback, parent=self)
                                                                                                                                                              self.installEventFilter(eventfilter)
                                                                                                                                                              return eventfilter
                                                                                                                                                      
                                                                                                                                                          def serialize(self) -> dict[str, Any]:
                                                                                                                                                              return self.get_properties()
                                                                                                                                                              # dct = {}
                                                                                                                                                              # for klass in reversed(inspect.getmro(type(self))):
                                                                                                                                                              #     if "serialize_fields" in klass.__dict__:
                                                                                                                                                              #         data = klass.serialize_fields(self)
                                                                                                                                                              #         dct |= data
                                                                                                                                                              # return dct
                                                                                                                                                      
                                                                                                                                                          @contextlib.contextmanager
                                                                                                                                                          def signals_blocked(self):
                                                                                                                                                              """Context manager to temporarily block emitting signals."""
                                                                                                                                                              blocked = self.blockSignals(True)
                                                                                                                                                              try:
                                                                                                                                                                  yield self
                                                                                                                                                              finally:
                                                                                                                                                                  self.blockSignals(blocked)
                                                                                                                                                      
                                                                                                                                                          @contextlib.contextmanager
                                                                                                                                                          def signal_blocked(
                                                                                                                                                              self, signal: core.SignalInstance, receiver: Callable | core.SignalInstance
                                                                                                                                                          ):
                                                                                                                                                              """Context manager to temporarily disconnect specific signal."""
                                                                                                                                                              signal.disconnect(receiver)
                                                                                                                                                              try:
                                                                                                                                                                  yield self
                                                                                                                                                              finally:
                                                                                                                                                                  signal.connect(receiver)
                                                                                                                                                      
                                                                                                                                                          @contextlib.contextmanager
                                                                                                                                                          def properties_set_to(self, **kwargs):
                                                                                                                                                              """Context manager to temporarily set properties to different values."""
                                                                                                                                                              props = {k: self.property(k) for k in kwargs}
                                                                                                                                                              for k, v in kwargs.items():
                                                                                                                                                                  self.setProperty(k, v)
                                                                                                                                                              try:
                                                                                                                                                                  yield self
                                                                                                                                                              finally:
                                                                                                                                                                  for k, v in props.items():
                                                                                                                                                                      self.setProperty(k, v)
                                                                                                                                                      
                                                                                                                                                          def to_json(self):
                                                                                                                                                              dct = self.__getstate__()
                                                                                                                                                              for k, v in dct.items():
                                                                                                                                                                  if isinstance(v, ObjectMixin):
                                                                                                                                                                      dct[k] = v.to_json()
                                                                                                                                                              return dct
                                                                                                                                                      
                                                                                                                                                          def set_unique_id(self):
                                                                                                                                                              """Set unique objectName."""
                                                                                                                                                              class_name = type(self).__name__
                                                                                                                                                              count = next(counter_dict[class_name])
                                                                                                                                                              self.setObjectName(f"{class_name}_{count}")
                                                                                                                                                      
                                                                                                                                                          def set_object_name(self, name: str):
                                                                                                                                                              """Set unique objectName."""
                                                                                                                                                              self.setObjectName(name)
                                                                                                                                                      
                                                                                                                                                          @classmethod
                                                                                                                                                          def get_qt_base_class(cls) -> type | None:
                                                                                                                                                              return classhelpers.get_qt_parent_class(cls)
                                                                                                                                                      
                                                                                                                                                          @classmethod
                                                                                                                                                          def get_static_metaobject(cls) -> core.MetaObject:
                                                                                                                                                              return _get_metaobject(cls)
                                                                                                                                                      
                                                                                                                                                          def get_metaobject(self) -> core.MetaObject:
                                                                                                                                                              return core.MetaObject(self.metaObject())
                                                                                                                                                      
                                                                                                                                                          def get_sender(self, typ: type[T]) -> T | None:
                                                                                                                                                              sender = self.sender()
                                                                                                                                                              return sender if isinstance(sender, typ) else None
                                                                                                                                                      
                                                                                                                                                          def find_children(
                                                                                                                                                              self,
                                                                                                                                                              typ: type[T] = core.QObject,  # ty: ignore[invalid-parameter-default]
                                                                                                                                                              name: str | datatypes.PatternType | None = None,
                                                                                                                                                              recursive: bool = True,
                                                                                                                                                              property_selector: dict[str, Any] | None = None,
                                                                                                                                                              only_prettyqt_classes: bool = False,
                                                                                                                                                          ) -> listdelegators.ListDelegator[T]:
                                                                                                                                                              """Find children with given type and name.
                                                                                                                                                      
                                                                                                                                                              Children can be filtered by passing a property selector dictionary.
                                                                                                                                                              It must contain the property name for keys and either a value which must be set
                                                                                                                                                              or a predicate function which gets the property value as an argument
                                                                                                                                                              and must return True if the child should be included.
                                                                                                                                                      
                                                                                                                                                              Arguments:
                                                                                                                                                                  typ: Subclass of QObject (can also be a UnionType)
                                                                                                                                                                  name: ObjectName filter. None includes all.
                                                                                                                                                                  recursive: whether to search for children recursively.
                                                                                                                                                                  property_selector: dict containing PropertyName -> Value/Predicate pairs.
                                                                                                                                                                  only_prettyqt_classes: only include objects with prettyqt superpowers.
                                                                                                                                                      
                                                                                                                                                              Returns:
                                                                                                                                                                  list of QObjects
                                                                                                                                                              """
                                                                                                                                                              if isinstance(name, re.Pattern):
                                                                                                                                                                  name = core.RegularExpression(name)
                                                                                                                                                              if recursive:
                                                                                                                                                                  flag = constants.FindChildOption.FindChildrenRecursively
                                                                                                                                                              else:
                                                                                                                                                                  flag = constants.FindChildOption.FindDirectChildrenOnly
                                                                                                                                                              match typ:
                                                                                                                                                                  case types.UnionType():
                                                                                                                                                                      objects = [
                                                                                                                                                                          i for t in get_args(typ) for i in self._find_children(t, name, flag)
                                                                                                                                                                      ]
                                                                                                                                                                  case type():
                                                                                                                                                                      objects = self._find_children(typ, name, flag)
                                                                                                                                                                  case _:
                                                                                                                                                                      raise TypeError(typ)
                                                                                                                                                              if property_selector:
                                                                                                                                                                  objects = [
                                                                                                                                                                      o
                                                                                                                                                                      for o in objects
                                                                                                                                                                      if all(
                                                                                                                                                                          v(o.property(k)) if callable(v) else o.property(k) == v
                                                                                                                                                                          for k, v in property_selector.items()
                                                                                                                                                                      )
                                                                                                                                                                  ]
                                                                                                                                                              if only_prettyqt_classes:
                                                                                                                                                                  objects = [i for i in objects if i.__module__.startswith("prettyqt")]
                                                                                                                                                              return listdelegators.ListDelegator(objects)
                                                                                                                                                      
                                                                                                                                                          def _find_children(
                                                                                                                                                              self,
                                                                                                                                                              typ: type[T],
                                                                                                                                                              name: str | core.QRegularExpression | None,
                                                                                                                                                              flag: constants.FindChildOption,
                                                                                                                                                          ) -> list[T]:
                                                                                                                                                              if name is None:
                                                                                                                                                                  return self.findChildren(typ, options=flag)
                                                                                                                                                              return self.findChildren(typ, name, options=flag)
                                                                                                                                                      
                                                                                                                                                          def find_child(
                                                                                                                                                              self,
                                                                                                                                                              typ: type[T] = core.QObject,  # ty: ignore[invalid-parameter-default]
                                                                                                                                                              name: str | core.QRegularExpression | None = None,
                                                                                                                                                              recursive: bool = True,
                                                                                                                                                          ) -> T | None:
                                                                                                                                                              """Find a child with given type and name."""
                                                                                                                                                              if recursive:
                                                                                                                                                                  flag = constants.FindChildOption.FindChildrenRecursively
                                                                                                                                                              else:
                                                                                                                                                                  flag = constants.FindChildOption.FindDirectChildrenOnly
                                                                                                                                                              match typ:
                                                                                                                                                                  case types.UnionType():
                                                                                                                                                                      return next(
                                                                                                                                                                          (item for item in self.find_children(typ, name, recursive=recursive)),
                                                                                                                                                                          None,
                                                                                                                                                                      )
                                                                                                                                                      
                                                                                                                                                                  case _:
                                                                                                                                                                      return self.findChild(typ, name, flag)  # type: ignore
                                                                                                                                                      
                                                                                                                                                          def find_parent(
                                                                                                                                                              self,
                                                                                                                                                              typ: type[T] = core.QObject,  # ty: ignore[invalid-parameter-default]
                                                                                                                                                              name: str | None = None,
                                                                                                                                                          ) -> T | None:
                                                                                                                                                              """Find parent with given type or name."""
                                                                                                                                                              node = self
                                                                                                                                                              while node:
                                                                                                                                                                  node = node.parent()
                                                                                                                                                                  if isinstance(node, typ) and (name is None or node.objectName() == name):
                                                                                                                                                                      return node
                                                                                                                                                              return None
                                                                                                                                                      
                                                                                                                                                          def start_timer(
                                                                                                                                                              self,
                                                                                                                                                              interval: int | str,
                                                                                                                                                              timer_type: constants.TimerTypeStr = "coarse",
                                                                                                                                                          ) -> int | None:
                                                                                                                                                              """Start a timer and return the timer id, to be used in timerEvent."""
                                                                                                                                                              if isinstance(interval, str):
                                                                                                                                                                  interval = helpers.parse_time(interval)
                                                                                                                                                              result = self.startTimer(interval, constants.TIMER_TYPE[timer_type])
                                                                                                                                                              return None if result == 0 else result
                                                                                                                                                      
                                                                                                                                                          def start_callback_timer(
                                                                                                                                                              self,
                                                                                                                                                              callback: Callable,
                                                                                                                                                              interval: int | str,
                                                                                                                                                              single_shot: bool = False,
                                                                                                                                                              timer_type: constants.TimerTypeStr = "coarse",
                                                                                                                                                          ) -> core.Timer:
                                                                                                                                                              """Start timer and execute callback when timeout reached."""
                                                                                                                                                              interval = helpers.parse_time(interval) if isinstance(interval, str) else interval
                                                                                                                                                              timer = core.Timer(
                                                                                                                                                                  self,
                                                                                                                                                                  single_shot=single_shot,
                                                                                                                                                                  interval=interval,
                                                                                                                                                                  timer_type=timer_type,
                                                                                                                                                                  timeout=callback,
                                                                                                                                                              )
                                                                                                                                                              timer.start()
                                                                                                                                                              return timer
                                                                                                                                                      
                                                                                                                                                          def get_properties(
                                                                                                                                                              self,
                                                                                                                                                              include_super: bool = True,
                                                                                                                                                              cast: bool = True,
                                                                                                                                                              only_writable: bool = False,
                                                                                                                                                              only_nonempty: bool = False,
                                                                                                                                                          ) -> dict[str, Any]:
                                                                                                                                                              """Get a dictionary containing all properties and their values."""
                                                                                                                                                              metaobj = self.get_metaobject()
                                                                                                                                                              props = metaobj.get_properties(
                                                                                                                                                                  include_super=include_super, only_writable=only_writable
                                                                                                                                                              )
                                                                                                                                                              dct = {}
                                                                                                                                                              for i in props:
                                                                                                                                                                  if i.get_name() in ["children", "frameShadow", "state"]:
                                                                                                                                                                      continue
                                                                                                                                                                  val = i.read(self)
                                                                                                                                                                  if only_nonempty:
                                                                                                                                                                      match val:
                                                                                                                                                                          case _ if hasattr(val, "isNull"):
                                                                                                                                                                              include = not val.isNull()
                                                                                                                                                                          case _ if hasattr(val, "isEmpty"):
                                                                                                                                                                              include = not val.isEmpty()
                                                                                                                                                                          case _ if hasattr(val, "isValid"):
                                                                                                                                                                              include = val.isValid()
                                                                                                                                                                          case _:
                                                                                                                                                                              include = bool(val)
                                                                                                                                                                  else:
                                                                                                                                                                      include = True
                                                                                                                                                                  if not include:
                                                                                                                                                                      continue
                                                                                                                                                                  dct[i.name()] = datatypes.make_serializable(val) if cast else val
                                                                                                                                                              return dct
                                                                                                                                                      
                                                                                                                                                          def set_properties(self, props: dict[str, Any], include_super: bool = True):
                                                                                                                                                              """Set properties from a dictionary."""
                                                                                                                                                              metaobj = self.get_metaobject()
                                                                                                                                                              metaprops = metaobj.get_properties(include_super=include_super)
                                                                                                                                                              for metaprop in metaprops:
                                                                                                                                                                  if (name := metaprop.name()) in props:
                                                                                                                                                                      value = props[name]
                                                                                                                                                                      metaprop.write(self, value)
                                                                                                                                                      
                                                                                                                                                          def get_dynamic_properties(self) -> dict[str, Any]:
                                                                                                                                                              """Get a dictionary with all dynamic properties."""
                                                                                                                                                              return {
                                                                                                                                                                  (k := bytes(i.data()).decode()): self.property(k)
                                                                                                                                                                  for i in self.dynamicPropertyNames()
                                                                                                                                                              }
                                                                                                                                                      
                                                                                                                                                          def bind_property(self, object_name: str, prop_name: str) -> property:
                                                                                                                                                              def getter(self):
                                                                                                                                                                  return self.findChild(core.QObject, object_name).property(prop_name)
                                                                                                                                                      
                                                                                                                                                              def setter(self, value):
                                                                                                                                                                  self.findChild(core.QObject, object_name).setProperty(prop_name, value)
                                                                                                                                                      
                                                                                                                                                              return property(getter, setter)
                                                                                                                                                      

                                                                                                                                                      add_callback_for_event(callback: Callable[[core.QEvent], bool], include: core.QEvent.Type | core.event.TypeStr | Sequence[core.QEvent.Type | core.event.TypeStr] | None = None, exclude: core.QEvent.Type | core.event.TypeStr | Sequence[core.QEvent.Type | core.event.TypeStr] | None = None) -> eventfilters.EventCatcher

                                                                                                                                                      Connect widget events to a callback.

                                                                                                                                                      if include is set, it behaves like a whitelist. if exclude is set, it behaves like a blacklist. The QEvent is passed to the callback as an argument, and the callback needs to return True or False to indicate whether the Event should be filtered.

                                                                                                                                                      Parameters:

                                                                                                                                                      Name Type Description Default
                                                                                                                                                      callback Callable[[QEvent], bool]

                                                                                                                                                      Callback to execute when event is triggered

                                                                                                                                                      required
                                                                                                                                                      include Type | TypeStr | Sequence[Type | TypeStr] | None

                                                                                                                                                      Events to include

                                                                                                                                                      None
                                                                                                                                                      exclude Type | TypeStr | Sequence[Type | TypeStr] | None

                                                                                                                                                      Events to exclude

                                                                                                                                                      None
                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def add_callback_for_event(
                                                                                                                                                          self,
                                                                                                                                                          callback: Callable[[core.QEvent], bool],
                                                                                                                                                          include: core.QEvent.Type
                                                                                                                                                          | core.event.TypeStr
                                                                                                                                                          | Sequence[core.QEvent.Type | core.event.TypeStr]
                                                                                                                                                          | None = None,
                                                                                                                                                          exclude: core.QEvent.Type
                                                                                                                                                          | core.event.TypeStr
                                                                                                                                                          | Sequence[core.QEvent.Type | core.event.TypeStr]
                                                                                                                                                          | None = None,
                                                                                                                                                      ) -> eventfilters.EventCatcher:
                                                                                                                                                          """Connect widget events to a callback.
                                                                                                                                                      
                                                                                                                                                          if include is set, it behaves like a whitelist.
                                                                                                                                                          if exclude is set, it behaves like a blacklist.
                                                                                                                                                          The QEvent is passed to the callback as an argument, and the callback
                                                                                                                                                          needs to return True or False to indicate whether the Event should be filtered.
                                                                                                                                                      
                                                                                                                                                          Arguments:
                                                                                                                                                              callback: Callback to execute when event is triggered
                                                                                                                                                              include: Events to include
                                                                                                                                                              exclude: Events to exclude
                                                                                                                                                          """
                                                                                                                                                          from prettyqt import eventfilters
                                                                                                                                                      
                                                                                                                                                          eventfilter = eventfilters.EventCatcher(include, exclude, callback, parent=self)
                                                                                                                                                          self.installEventFilter(eventfilter)
                                                                                                                                                          return eventfilter
                                                                                                                                                      

                                                                                                                                                      find_child(typ: type[T] = core.QObject, name: str | core.QRegularExpression | None = None, recursive: bool = True) -> T | None

                                                                                                                                                      Find a child with given type and name.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def find_child(
                                                                                                                                                          self,
                                                                                                                                                          typ: type[T] = core.QObject,  # ty: ignore[invalid-parameter-default]
                                                                                                                                                          name: str | core.QRegularExpression | None = None,
                                                                                                                                                          recursive: bool = True,
                                                                                                                                                      ) -> T | None:
                                                                                                                                                          """Find a child with given type and name."""
                                                                                                                                                          if recursive:
                                                                                                                                                              flag = constants.FindChildOption.FindChildrenRecursively
                                                                                                                                                          else:
                                                                                                                                                              flag = constants.FindChildOption.FindDirectChildrenOnly
                                                                                                                                                          match typ:
                                                                                                                                                              case types.UnionType():
                                                                                                                                                                  return next(
                                                                                                                                                                      (item for item in self.find_children(typ, name, recursive=recursive)),
                                                                                                                                                                      None,
                                                                                                                                                                  )
                                                                                                                                                      
                                                                                                                                                              case _:
                                                                                                                                                                  return self.findChild(typ, name, flag)  # type: ignore
                                                                                                                                                      

                                                                                                                                                      find_children(typ: type[T] = core.QObject, name: str | datatypes.PatternType | None = None, recursive: bool = True, property_selector: dict[str, Any] | None = None, only_prettyqt_classes: bool = False) -> listdelegators.ListDelegator[T]

                                                                                                                                                      Find children with given type and name.

                                                                                                                                                      Children can be filtered by passing a property selector dictionary. It must contain the property name for keys and either a value which must be set or a predicate function which gets the property value as an argument and must return True if the child should be included.

                                                                                                                                                      Parameters:

                                                                                                                                                      Name Type Description Default
                                                                                                                                                      typ type[T]

                                                                                                                                                      Subclass of QObject (can also be a UnionType)

                                                                                                                                                      QObject
                                                                                                                                                      name str | PatternType | None

                                                                                                                                                      ObjectName filter. None includes all.

                                                                                                                                                      None
                                                                                                                                                      recursive bool

                                                                                                                                                      whether to search for children recursively.

                                                                                                                                                      True
                                                                                                                                                      property_selector dict[str, Any] | None

                                                                                                                                                      dict containing PropertyName -> Value/Predicate pairs.

                                                                                                                                                      None
                                                                                                                                                      only_prettyqt_classes bool

                                                                                                                                                      only include objects with prettyqt superpowers.

                                                                                                                                                      False
                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def find_children(
                                                                                                                                                          self,
                                                                                                                                                          typ: type[T] = core.QObject,  # ty: ignore[invalid-parameter-default]
                                                                                                                                                          name: str | datatypes.PatternType | None = None,
                                                                                                                                                          recursive: bool = True,
                                                                                                                                                          property_selector: dict[str, Any] | None = None,
                                                                                                                                                          only_prettyqt_classes: bool = False,
                                                                                                                                                      ) -> listdelegators.ListDelegator[T]:
                                                                                                                                                          """Find children with given type and name.
                                                                                                                                                      
                                                                                                                                                          Children can be filtered by passing a property selector dictionary.
                                                                                                                                                          It must contain the property name for keys and either a value which must be set
                                                                                                                                                          or a predicate function which gets the property value as an argument
                                                                                                                                                          and must return True if the child should be included.
                                                                                                                                                      
                                                                                                                                                          Arguments:
                                                                                                                                                              typ: Subclass of QObject (can also be a UnionType)
                                                                                                                                                              name: ObjectName filter. None includes all.
                                                                                                                                                              recursive: whether to search for children recursively.
                                                                                                                                                              property_selector: dict containing PropertyName -> Value/Predicate pairs.
                                                                                                                                                              only_prettyqt_classes: only include objects with prettyqt superpowers.
                                                                                                                                                      
                                                                                                                                                          Returns:
                                                                                                                                                              list of QObjects
                                                                                                                                                          """
                                                                                                                                                          if isinstance(name, re.Pattern):
                                                                                                                                                              name = core.RegularExpression(name)
                                                                                                                                                          if recursive:
                                                                                                                                                              flag = constants.FindChildOption.FindChildrenRecursively
                                                                                                                                                          else:
                                                                                                                                                              flag = constants.FindChildOption.FindDirectChildrenOnly
                                                                                                                                                          match typ:
                                                                                                                                                              case types.UnionType():
                                                                                                                                                                  objects = [
                                                                                                                                                                      i for t in get_args(typ) for i in self._find_children(t, name, flag)
                                                                                                                                                                  ]
                                                                                                                                                              case type():
                                                                                                                                                                  objects = self._find_children(typ, name, flag)
                                                                                                                                                              case _:
                                                                                                                                                                  raise TypeError(typ)
                                                                                                                                                          if property_selector:
                                                                                                                                                              objects = [
                                                                                                                                                                  o
                                                                                                                                                                  for o in objects
                                                                                                                                                                  if all(
                                                                                                                                                                      v(o.property(k)) if callable(v) else o.property(k) == v
                                                                                                                                                                      for k, v in property_selector.items()
                                                                                                                                                                  )
                                                                                                                                                              ]
                                                                                                                                                          if only_prettyqt_classes:
                                                                                                                                                              objects = [i for i in objects if i.__module__.startswith("prettyqt")]
                                                                                                                                                          return listdelegators.ListDelegator(objects)
                                                                                                                                                      

                                                                                                                                                      find_parent(typ: type[T] = core.QObject, name: str | None = None) -> T | None

                                                                                                                                                      Find parent with given type or name.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def find_parent(
                                                                                                                                                          self,
                                                                                                                                                          typ: type[T] = core.QObject,  # ty: ignore[invalid-parameter-default]
                                                                                                                                                          name: str | None = None,
                                                                                                                                                      ) -> T | None:
                                                                                                                                                          """Find parent with given type or name."""
                                                                                                                                                          node = self
                                                                                                                                                          while node:
                                                                                                                                                              node = node.parent()
                                                                                                                                                              if isinstance(node, typ) and (name is None or node.objectName() == name):
                                                                                                                                                                  return node
                                                                                                                                                          return None
                                                                                                                                                      

                                                                                                                                                      get_dynamic_properties() -> dict[str, Any]

                                                                                                                                                      Get a dictionary with all dynamic properties.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def get_dynamic_properties(self) -> dict[str, Any]:
                                                                                                                                                          """Get a dictionary with all dynamic properties."""
                                                                                                                                                          return {
                                                                                                                                                              (k := bytes(i.data()).decode()): self.property(k)
                                                                                                                                                              for i in self.dynamicPropertyNames()
                                                                                                                                                          }
                                                                                                                                                      

                                                                                                                                                      get_properties(include_super: bool = True, cast: bool = True, only_writable: bool = False, only_nonempty: bool = False) -> dict[str, Any]

                                                                                                                                                      Get a dictionary containing all properties and their values.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def get_properties(
                                                                                                                                                          self,
                                                                                                                                                          include_super: bool = True,
                                                                                                                                                          cast: bool = True,
                                                                                                                                                          only_writable: bool = False,
                                                                                                                                                          only_nonempty: bool = False,
                                                                                                                                                      ) -> dict[str, Any]:
                                                                                                                                                          """Get a dictionary containing all properties and their values."""
                                                                                                                                                          metaobj = self.get_metaobject()
                                                                                                                                                          props = metaobj.get_properties(
                                                                                                                                                              include_super=include_super, only_writable=only_writable
                                                                                                                                                          )
                                                                                                                                                          dct = {}
                                                                                                                                                          for i in props:
                                                                                                                                                              if i.get_name() in ["children", "frameShadow", "state"]:
                                                                                                                                                                  continue
                                                                                                                                                              val = i.read(self)
                                                                                                                                                              if only_nonempty:
                                                                                                                                                                  match val:
                                                                                                                                                                      case _ if hasattr(val, "isNull"):
                                                                                                                                                                          include = not val.isNull()
                                                                                                                                                                      case _ if hasattr(val, "isEmpty"):
                                                                                                                                                                          include = not val.isEmpty()
                                                                                                                                                                      case _ if hasattr(val, "isValid"):
                                                                                                                                                                          include = val.isValid()
                                                                                                                                                                      case _:
                                                                                                                                                                          include = bool(val)
                                                                                                                                                              else:
                                                                                                                                                                  include = True
                                                                                                                                                              if not include:
                                                                                                                                                                  continue
                                                                                                                                                              dct[i.name()] = datatypes.make_serializable(val) if cast else val
                                                                                                                                                          return dct
                                                                                                                                                      

                                                                                                                                                      installEventFilter(filter_: core.QObject | str, **kwargs)

                                                                                                                                                      Override to also allow setting eventfilters by name.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def installEventFilter(self, filter_: core.QObject | str, **kwargs):
                                                                                                                                                          """Override to also allow setting eventfilters by name."""
                                                                                                                                                          if filter_ in self._eventfilters:
                                                                                                                                                              logger.warning("Installing same EventFilter multiple times to %s.", self)
                                                                                                                                                              return
                                                                                                                                                          match filter_:
                                                                                                                                                              case core.QObject():
                                                                                                                                                                  pass
                                                                                                                                                              case str():
                                                                                                                                                                  from prettyqt import eventfilters
                                                                                                                                                      
                                                                                                                                                                  kls = classhelpers.get_class_for_id(eventfilters.BaseEventFilter, filter_)
                                                                                                                                                                  filter_ = kls(parent=self, **kwargs)
                                                                                                                                                              case _:
                                                                                                                                                                  raise ValueError(filter_)
                                                                                                                                                          self._eventfilters.add(filter_)
                                                                                                                                                          super().installEventFilter(filter_)
                                                                                                                                                      

                                                                                                                                                      properties_set_to(**kwargs)

                                                                                                                                                      Context manager to temporarily set properties to different values.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      @contextlib.contextmanager
                                                                                                                                                      def properties_set_to(self, **kwargs):
                                                                                                                                                          """Context manager to temporarily set properties to different values."""
                                                                                                                                                          props = {k: self.property(k) for k in kwargs}
                                                                                                                                                          for k, v in kwargs.items():
                                                                                                                                                              self.setProperty(k, v)
                                                                                                                                                          try:
                                                                                                                                                              yield self
                                                                                                                                                          finally:
                                                                                                                                                              for k, v in props.items():
                                                                                                                                                                  self.setProperty(k, v)
                                                                                                                                                      

                                                                                                                                                      set_object_name(name: str)

                                                                                                                                                      Set unique objectName.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def set_object_name(self, name: str):
                                                                                                                                                          """Set unique objectName."""
                                                                                                                                                          self.setObjectName(name)
                                                                                                                                                      

                                                                                                                                                      set_properties(props: dict[str, Any], include_super: bool = True)

                                                                                                                                                      Set properties from a dictionary.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def set_properties(self, props: dict[str, Any], include_super: bool = True):
                                                                                                                                                          """Set properties from a dictionary."""
                                                                                                                                                          metaobj = self.get_metaobject()
                                                                                                                                                          metaprops = metaobj.get_properties(include_super=include_super)
                                                                                                                                                          for metaprop in metaprops:
                                                                                                                                                              if (name := metaprop.name()) in props:
                                                                                                                                                                  value = props[name]
                                                                                                                                                                  metaprop.write(self, value)
                                                                                                                                                      

                                                                                                                                                      set_unique_id()

                                                                                                                                                      Set unique objectName.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def set_unique_id(self):
                                                                                                                                                          """Set unique objectName."""
                                                                                                                                                          class_name = type(self).__name__
                                                                                                                                                          count = next(counter_dict[class_name])
                                                                                                                                                          self.setObjectName(f"{class_name}_{count}")
                                                                                                                                                      

                                                                                                                                                      signal_blocked(signal: core.SignalInstance, receiver: Callable | core.SignalInstance)

                                                                                                                                                      Context manager to temporarily disconnect specific signal.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      @contextlib.contextmanager
                                                                                                                                                      def signal_blocked(
                                                                                                                                                          self, signal: core.SignalInstance, receiver: Callable | core.SignalInstance
                                                                                                                                                      ):
                                                                                                                                                          """Context manager to temporarily disconnect specific signal."""
                                                                                                                                                          signal.disconnect(receiver)
                                                                                                                                                          try:
                                                                                                                                                              yield self
                                                                                                                                                          finally:
                                                                                                                                                              signal.connect(receiver)
                                                                                                                                                      

                                                                                                                                                      signals_blocked()

                                                                                                                                                      Context manager to temporarily block emitting signals.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      @contextlib.contextmanager
                                                                                                                                                      def signals_blocked(self):
                                                                                                                                                          """Context manager to temporarily block emitting signals."""
                                                                                                                                                          blocked = self.blockSignals(True)
                                                                                                                                                          try:
                                                                                                                                                              yield self
                                                                                                                                                          finally:
                                                                                                                                                              self.blockSignals(blocked)
                                                                                                                                                      

                                                                                                                                                      start_callback_timer(callback: Callable, interval: int | str, single_shot: bool = False, timer_type: constants.TimerTypeStr = 'coarse') -> core.Timer

                                                                                                                                                      Start timer and execute callback when timeout reached.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def start_callback_timer(
                                                                                                                                                          self,
                                                                                                                                                          callback: Callable,
                                                                                                                                                          interval: int | str,
                                                                                                                                                          single_shot: bool = False,
                                                                                                                                                          timer_type: constants.TimerTypeStr = "coarse",
                                                                                                                                                      ) -> core.Timer:
                                                                                                                                                          """Start timer and execute callback when timeout reached."""
                                                                                                                                                          interval = helpers.parse_time(interval) if isinstance(interval, str) else interval
                                                                                                                                                          timer = core.Timer(
                                                                                                                                                              self,
                                                                                                                                                              single_shot=single_shot,
                                                                                                                                                              interval=interval,
                                                                                                                                                              timer_type=timer_type,
                                                                                                                                                              timeout=callback,
                                                                                                                                                          )
                                                                                                                                                          timer.start()
                                                                                                                                                          return timer
                                                                                                                                                      

                                                                                                                                                      start_timer(interval: int | str, timer_type: constants.TimerTypeStr = 'coarse') -> int | None

                                                                                                                                                      Start a timer and return the timer id, to be used in timerEvent.

                                                                                                                                                      Source code in prettyqt/core/object.py
                                                                                                                                                      def start_timer(
                                                                                                                                                          self,
                                                                                                                                                          interval: int | str,
                                                                                                                                                          timer_type: constants.TimerTypeStr = "coarse",
                                                                                                                                                      ) -> int | None:
                                                                                                                                                          """Start a timer and return the timer id, to be used in timerEvent."""
                                                                                                                                                          if isinstance(interval, str):
                                                                                                                                                              interval = helpers.parse_time(interval)
                                                                                                                                                          result = self.startTimer(interval, constants.TIMER_TYPE[timer_type])
                                                                                                                                                          return None if result == 0 else result
                                                                                                                                                      

                                                                                                                                                      :fa-brands-github: Show source on GitHub